package code16_thread;

public class Test02 {

	public static void main(String[] args) {
		// 2.创建 MyRun 对象
		MyRun mr = new MyRun();
		// 3.创建 线程对象, 需要传入 Runnable 的对象
		Thread t = new Thread(mr, "tom");
		// 4.启动线程
		t.start();
		
		
		MyRun mr2 = new MyRun();
		Thread t2 = new Thread(mr2, "jerry");
		t2.start();
	}
}
// 1.实现 Runnable
class MyRun implements Runnable {
	@Override
	public void run() {
		// 线程需要执行的任务代码
		for (int i = 0; i < 100; i++) {
			Thread thread = Thread.currentThread();
			System.out.println(thread.getName() + ":" + i);
		}
	}
}